﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GolfScoringApplication
{
    public partial class frmEmail : Form
    {
        private frmGolfer _frmParent;

        public frmEmail()
        {
            InitializeComponent();
        }

        private void frmEmail_Load(object sender, EventArgs e)
        {
            LoadEmailType();
        }

        public void LoadFormVariables(frmGolfer frmParent)
        {
            _frmParent = frmParent;

        }

        private void LoadEmailType()
        {
            cboEmailType.Items.Clear();
            cboEmailType.Items.Add(EmailType.Home.ToString());
            cboEmailType.Items.Add(EmailType.Work.ToString());
            cboEmailType.Items.Add(EmailType.Family.ToString());
            cboEmailType.SelectedIndex = 0;
        }

        private void cmdAdd_Click(object sender, EventArgs e)
        {
            EmailType objType = EmailType.Work;
            
            switch (cboEmailType.SelectedItem.ToString())
            {
                case "Family":
                    {
                        objType = EmailType.Family;
                        break;
                    }
                case "Home":
                    {
                        objType = EmailType.Home;
                        break;
                    }
                case "Work":
                    {
                        objType = EmailType.Work;
                        break;
                    }

            }

            EmailAddress objEmail = new EmailAddress(txtEmail.Text, objType);
            _frmParent.AddEmail(objEmail);
            this.Close();

        }

    }
}
